package _03TCP通信;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8888);

        Socket socket = serverSocket.accept();

        InputStream is = socket.getInputStream();

        byte[] bytes = new byte[1024];
        int read = is.read(bytes);
        System.out.println("客户端发送的："+new String(bytes,0,read));
        OutputStream os = socket.getOutputStream();
        os.write("客户端，你好".getBytes());

        os.close();
        is.close();
        socket.close();
        serverSocket.close();

    }
}
